package com.dody.agile.payment.employee;


import com.dody.agile.payment.affilication.Affiliation;
import com.dody.agile.payment.affilication.NoAffiliation;
import com.dody.agile.payment.affilication.UnionAffiliation;
import com.dody.agile.payment.classification.PaymentClassification;
import com.dody.agile.payment.method.PaymentMethod;
import com.dody.agile.payment.model.PayDate;
import com.dody.agile.payment.model.Paycheck;
import com.dody.agile.payment.schedule.PaymentSchedule;

import java.util.Date;

/**
 * @author ShiXin
 * @date 2019/4/9 20:16
 * @description ExamStack
 */
public class Employee {

    private Integer id;
    private String address;
    private String name;
    private PaymentClassification classification;
    private PaymentSchedule schedule;
    private PaymentMethod paymentMethod;
    private Affiliation affiliation = new NoAffiliation();

    public Employee(Integer id, String address, String name) {
        this.id = id;
        this.address = address;
        this.name = name;
    }

    public boolean isPayDay(Date d) {
        return this.schedule.isPayDay(d);
    }

    public void payDay(Paycheck pc){
        double grossPay = classification.calculatePay(pc);
        double deductions = affiliation.calculateDeductions(pc);
        double netPay = grossPay - deductions;
        pc.setGrossPay(grossPay);
        pc.setDeductions(deductions);
        pc.setNetPay(netPay);
        paymentMethod.pay(pc);
    }

    public Date getPayPeriodStartDate(Date d) {
        return this.schedule.getPayPeriodStartDate(d);
    }


    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public PaymentClassification getClassification() {
        return classification;
    }

    public void setClassification(PaymentClassification classification) {
        this.classification = classification;
    }

    public PaymentSchedule getSchedule() {
        return schedule;
    }

    public void setSchedule(PaymentSchedule schedule) {
        this.schedule = schedule;
    }

    public PaymentMethod getMethod() {
        return paymentMethod;
    }

    public void setMethod(PaymentMethod method) {
        this.paymentMethod = method;
    }

    public void setAffiliation(Affiliation af) {
        this.affiliation = af;
    }

    public Affiliation getAffiliation() {
        return this.affiliation;
    }
}
